#include "../Header/Input.h"

Input ::Input(GameObject * inputPointerToPlayer)
{
	pointerToPlayer = inputPointerToPlayer;
}
void Input :: ReceiveMessage(Message *msg)
{
	int character = static_cast<KeyDownMessage*>(msg)->GetKey();
	
	Vec2 inputVector;

	inputVector.x = 0;
	inputVector.y = 0;

	int moveDist = 10;

	int ClientHeight = 512;
	int ClientWidth = 512;

	int playerHeight = pointerToPlayer->getDimension().y;
	int playerWidth = pointerToPlayer->getDimension().x;

	switch (character)
	{
	case 'w':
		inputVector.x = 0;
		inputVector.y = moveDist;
		break;
	case 's':
		inputVector.x = 0;
		inputVector.y = -moveDist;
		break;
	case 'a':
		inputVector.x = -moveDist;
		inputVector.y = 0;
		break;
	case 'd':
		inputVector.x = moveDist;
		inputVector.y = 0;
		break;
	default:
		break;
	}
	static_cast<Movable * >(pointerToPlayer->getComponent("Movable"))->Move(inputVector);
}
void Input::Update(float frameTime)
{

}